<template>
  <div>
    <Table :param="tableParam"></Table>
  </div>
</template>

<script>
  import Table from './Table'
  export default {
    components: {
      Table
    },
    data(){
      return {
        tableParam: {
          //表头
          title: [
            {title:"课程编号", attr:"id"},
            {title:"课程名称", attr:"cname"},
            {title:"课程分类", attr:"tpid"},
            {title:"价格", attr:"price", other: (data) => {
              return data ? data : '免费';
            }}
          ],
          //请求的url
          url: "/course/list",
          //请求的数据
          data: {},
          //后续的操作按钮
          btns: {
            enable: true,
            //操作列表
            actions: [
              {
                btnName: "开始上课", isShow: (val) => {
                    return true;
                }, callable: (val) => {
                  console.log("开始上课...", val);

                  //使用新的窗口打开课程直播间
                  const routeUrl = this.$router.resolve({
                      path: "/CoursePlayer/" + val.id + "/" + val.cname
                  });
                  window.open(routeUrl.href, "_blank");
                }
              }
            ]
          },
          //分页参数
          page: {
            //是否需要开启分页的功能
            enable: true,
            //当前第几页
            pageNum: 1,
            //每页多少行记录
            pageSize: 7
          }
        }
      }
    }
  }
</script>

<style>
</style>
